<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>run (Spec::DSL::Behaviour)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File vendor\plugins\rspec/lib/spec/dsl/behaviour.rb, line 64</span>
      <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>(<span class="ruby-identifier">reporter</span>, <span class="ruby-identifier">dry_run</span>=<span class="ruby-keyword kw">false</span>, <span class="ruby-identifier">reverse</span>=<span class="ruby-keyword kw">false</span>, <span class="ruby-identifier">timeout</span>=<span class="ruby-keyword kw">nil</span>)
        <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;shared behaviours should never run&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">shared?</span>
        <span class="ruby-comment cmt"># TODO - change add_behaviour to add_description ??????</span>
        <span class="ruby-identifier">reporter</span>.<span class="ruby-identifier">add_behaviour</span>(<span class="ruby-ivar">@description</span>)
        <span class="ruby-identifier">prepare_execution_context_class</span>
        <span class="ruby-identifier">before_all_errors</span> = <span class="ruby-identifier">run_before_all</span>(<span class="ruby-identifier">reporter</span>, <span class="ruby-identifier">dry_run</span>)

        <span class="ruby-identifier">exs</span> = <span class="ruby-identifier">reverse</span> <span class="ruby-value">? </span><span class="ruby-identifier">examples</span>.<span class="ruby-identifier">reverse</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">examples</span>
        <span class="ruby-identifier">example_execution_context</span> = <span class="ruby-keyword kw">nil</span>
         
        <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">before_all_errors</span>.<span class="ruby-identifier">empty?</span>
          <span class="ruby-identifier">exs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">example</span><span class="ruby-operator">|</span>
            <span class="ruby-identifier">example_execution_context</span> = <span class="ruby-identifier">execution_context</span>(<span class="ruby-identifier">example</span>)
            <span class="ruby-identifier">example_execution_context</span>.<span class="ruby-identifier">copy_instance_variables_from</span>(<span class="ruby-ivar">@before_and_after_all_context_instance</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">before_all_proc</span>(<span class="ruby-identifier">behaviour_type</span>).<span class="ruby-identifier">nil?</span>
            
            <span class="ruby-identifier">befores</span> = <span class="ruby-identifier">before_each_proc</span>(<span class="ruby-identifier">behaviour_type</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>}
            <span class="ruby-identifier">afters</span> = <span class="ruby-identifier">after_each_proc</span>(<span class="ruby-identifier">behaviour_type</span>)
            <span class="ruby-identifier">example</span>.<span class="ruby-identifier">run</span>(<span class="ruby-identifier">reporter</span>, <span class="ruby-identifier">befores</span>, <span class="ruby-identifier">afters</span>, <span class="ruby-identifier">dry_run</span>, <span class="ruby-identifier">example_execution_context</span>, <span class="ruby-identifier">timeout</span>)
          <span class="ruby-keyword kw">end</span>
        <span class="ruby-keyword kw">end</span>
        
        <span class="ruby-ivar">@before_and_after_all_context_instance</span>.<span class="ruby-identifier">copy_instance_variables_from</span>(<span class="ruby-identifier">example_execution_context</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">after_all_proc</span>(<span class="ruby-identifier">behaviour_type</span>).<span class="ruby-identifier">nil?</span>
        <span class="ruby-identifier">run_after_all</span>(<span class="ruby-identifier">reporter</span>, <span class="ruby-identifier">dry_run</span>)
      <span class="ruby-keyword kw">end</span></pre>
</body>
</html>